package com.ocom.payconfig.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.payconfig.EntityXfMerchMoneyDay;
import com.ocom.common.request.payconfig.ConsMerchPayReportsRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDXfMerchMoneyDay extends BaseMapper<EntityXfMerchMoneyDay> {

    @Select({"<script>",
            "SELECT id, pay_date, merch_name, merch_no, pay_amount, manage_amount, now_received, now_receipts, ",
            "pay_state, trace_no, ret_msg, remark, merch_no_out, trace_no_out, repair_pay_date, create_time, update_time ",
            "FROM xf_merch_money_day ",
            "WHERE com_id=#{consMerchPayReportsRequest.comId} AND pay_date >= #{consMerchPayReportsRequest.beginDate}",
            "<if test='consMerchPayReportsRequest.endDate != null'>",
            "AND pay_date &lt;= #{consMerchPayReportsRequest.endDate}",
            "</if>",
            "<if test='consMerchPayReportsRequest.merchName != null'>",
            "AND merch_name LIKE CONCAT('%', #{consMerchPayReportsRequest.merchName}, '%')",
            "</if>",
            "<if test='consMerchPayReportsRequest.merchNo != null'>",
            "AND merch_no LIKE CONCAT('%', #{consMerchPayReportsRequest.merchNo}, '%')",
            "</if>",
            "<if test='consMerchPayReportsRequest.merchNoOut != null'>",
            "AND merch_no_out LIKE CONCAT('%', #{consMerchPayReportsRequest.merchNoOut}, '%')",
            "</if>",
            "<if test='consMerchPayReportsRequest.traceNo != null'>",
            "AND trace_no LIKE CONCAT('%', #{consMerchPayReportsRequest.traceNo}, '%')",
            "</if>",
            "<if test='consMerchPayReportsRequest.traceNoOut != null'>",
            "AND trace_no_out LIKE CONCAT('%', #{consMerchPayReportsRequest.traceNoOut}, '%')",
            "</if>",
            "<if test='consMerchPayReportsRequest.payState != null'>",
            "AND pay_state = #{consMerchPayReportsRequest.payState}",
            "</if>",
            "<if test='consMerchPayReportsRequest.id!=null'>",
            "AND id = #{consMerchPayReportsRequest.id}",
            "</if>",
            "ORDER BY pay_date DESC, merch_no, id",
            "</script>"})
    List<EntityXfMerchMoneyDay> selectMerchMoneyDayList(@Param("consMerchPayReportsRequest") ConsMerchPayReportsRequest consMerchPayReportsRequest);
}
